package com.ruoyi.law.service.impl;

import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.ruoyi.law.domain.entity.LawService;
import com.ruoyi.law.enums.OrderType;
import com.ruoyi.law.mapper.LawServiceMapper;
import com.ruoyi.law.service.ILawServiceService;
import com.ruoyi.law.service.ILawVipService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

/**
 * <p>
 * 咨询和服务 服务实现类
 * </p>
 *
 * @author code
 * @since 2022-11-25
 */
@Service
public class LawServiceServiceImpl extends ServiceImpl<LawServiceMapper, LawService> implements ILawServiceService {

    @Autowired
    private ILawVipService vipService;

    @Override
    public String getName(Long serviceId, String earningType) {
        if (OrderType.VIP.getType().equals(earningType)) {
            return vipService.getName(serviceId);
        } else if (OrderType.serviceOrder.getType().equals(earningType)
                || OrderType.consultingOrder.getType().equals(earningType)) {
            LawService byId = super.getById(serviceId);
            return byId == null ? "" : byId.getTitle();
        }
        return null;
    }
}
